package com.zw.mes.module.assemble.controller;

import com.zw.mes.base.BaseController;
import com.zw.mes.common.JsonResult;
import com.zw.mes.module.assemble.entity.AsseStore;
import com.zw.mes.module.assemble.model.StoreRecordModel;
import com.zw.mes.module.assemble.service.SelService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Description: 装配任务池 成品库池 成品库出入库记录 等查询页面
 * <p>
 * 权限：
 * @Author: China.wsg
 * @Date: 2021/04/22 16:12
 */
@Controller
@RequestMapping("/assemble/sel")
@SuppressWarnings("all")
public class SelController extends BaseController {

    @Autowired
    private SelService selService;

    /**
     * @Author wsg
     * @Date 09:51 2021/5/11
     * @Description 成品库出入库记录 页面
     **/
    @GetMapping("/recordPage")
    @RequiresPermissions({"asseOrd:finRecord:view"})
    public String recordPage() {
        return "assemble/sel/recordPage";
    }

    /**
     * @Author wsg
     * @Date 09:51 2021/5/11
     * @Description 成品库出入库记录 列表
     **/
    @ResponseBody
    @PostMapping("/recordList")
    @RequiresPermissions({"asseOrd:finRecord:view"})
    public JsonResult recordList(StoreRecordModel recordModel) {
        startPage();
        List<StoreRecordModel> list = selService.findRecordListByQuery(recordModel);
        return jsonResult(list);
    }

    /**
     * @Author wsg
     * @Date 13:20 2021/5/11
     * @Description 成品库池 页面
     **/
    @GetMapping("/storePage")
    @RequiresPermissions({"asseOrd:finished:view"})
    public String storePage(Model model) {
        model.addAttribute("prodNo", "");
        return "assemble/sel/storePage";
    }

    /**
     * @Author wsg
     * @Date 13:20 2021/5/11
     * @Description 成品库池 列表
     **/
    @ResponseBody
    @PostMapping("/storeList")
    @RequiresPermissions({"asseOrd:finished:view"})
    public JsonResult storeList(AsseStore asseStore) {
        startPage();
        List<AsseStore> list = selService.findAsseStoreListByQuery(asseStore);
        return jsonResult(list);
    }


}
